package com.bit.demo2;


import java.util.Objects;

class Student{
    public String name;
    public int age;

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }


    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
//equals  用来判断两个引用所引用的对象是不是一样的
    @Override
    public boolean equals(Object o) {
        if (this == o){
            return true;
        }if (o == null || getClass() != o.getClass()) {
            return false;
        }
        Student student = (Student) o;

        if (age == student.age && this.name.equals( student.name)){
            return true;
        }
        return false;
    }

  /*  @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }*/
}
interface Ishape{
    public void func();
}
class Test implements Ishape{

    @Override
    public void func() {
        System.out.println("hello");
    }
}
public class TestDemo2 {

    public static void main(String[] args) {
        Ishape shap = new Test();
        //接口给Object
        Object o = shap;
        Ishape shap1 = (Ishape) o;
        shap1.func();
    }

    public static void main2(String[] args) {
        //Objict接受数组对象，向上转型
        Object obj =new int[]{1,2,3,4,5,6};

        Object obj2 = new Double[]{1.0,2.5};
        //向下转型 需要强转
        int[] data = (int[]) obj;
        for (int i :data){
            System.out.println(i + "、");
        }
    }

    public static void main1(String[] args) {
        Student student1 = new Student("weiwei",18);
        //Student student2 = student1;
        Student student2 = new Student("weiwei",18);
        System.out.println(student1.equals(student2));

        System.out.println("==========对象的位置、在hashmap当中会使用倒=========");
        System.out.println(student1.hashCode());
        System.out.println(student2.hashCode());
    }

}
